public class example05 {
    public static void main(String[] args) {
        File file = new File("D:11file");
        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                File currFile = new File(dir, name);
                if (currFile.isFile() && name.endsWith(".txt")) {
                    return true;
                } else {
                    return false;
                }
            }
        };
        if (file.exists()) {
            String[] lists = file.list(filter);
            for (String list : lists) {
                System.out.println(list);
            }
        }
    }
}
